import axios from 'axios'
import qs from 'querystring'
//请求拦截
axios.interceptors.request.use(function(config){
    if(config.method.toLowerCase() === 'post'){
        config.headers={
            "content-type":"application/x-www-form-urlencoded"
        }
        if(config.data && typeof config.data === 'object'){
            config.data=qs.stringify(config.data)
        }
    }
    return config
})
//响应拦截
axios.interceptors.response.use(function(response){
    if(response.status ===200){
        return response.data
    }else{
        return response
    }
})

export default axios;